﻿using System;
using EPiServer.Core;
using EPiServer.Web.PropertyControls;
using System.Web.UI.WebControls;
using EPiServer.PlugIn;

namespace EPiServer.Labs.MobilePack.Site
{
    public enum Animation
    {
        slide,
        slideup,
        slidedown,
        pop,
        fade,
        flip
    }

    [Serializable, PageDefinitionTypePlugIn]
    public class PropertyAnimationDropDown : PropertyString
    {
        public override IPropertyControl CreatePropertyControl()
        {
            return new PropertyAnimationDropDownControl();
        }
    }

    public class PropertyAnimationDropDownControl : PropertySelectControlBase
    {
        protected override void SetupEditControls()
        {

            foreach (var item in Enum.GetNames(typeof(Animation)))
            {
                var listItem = new ListItem(item);
                EditControl.Items.Add(listItem);
                if (this.ToString() == item)
                {
                    listItem.Selected = true;
                }
            }
        }

        public override void ApplyEditChanges()
        {

            if (EditControl.SelectedValue != null)
            {
                SetValue(EditControl.SelectedValue);
            }
            else SetValue(null);
        }

    }
}